<template>
    <div class="basic-layout-page">
        <div class="basic-layout-header">
            <div class="left">
                <div class="title">{{ systemName }}</div>
                <div class="menu">
                    <a-menu mode="horizontal" theme="dark">
                        <template v-for="item in menuList">
                            <a-menu-item
                                v-if="!item.children"
                                :key="item.key"
                                @click="onItemClick(item.path)"
                            >
                                <!-- <a-icon :type="item.icon" /> -->
                                <span>{{ item.title }}</span>
                            </a-menu-item>
                            <sub-menu
                                v-else
                                :key="item.key"
                                :menu-info="item"
                                @onItemClick="onItemClick"
                            />
                        </template>
                    </a-menu>
                </div>
            </div>
            <div class="right">
                <a-dropdown>
                    <span>
                        <a-icon type="user" />
                        <span class="name">管理员1</span>
                        <a-icon type="down" />
                    </span>
                    <a-menu slot="overlay">
                        <a-menu-item>
                            <a-icon type="logout" style="color: red" />退出登录
                        </a-menu-item>
                    </a-menu>
                </a-dropdown>
            </div>
        </div>
        <div class="basic-layout-content">
            <div class="basic-layout-container">
                <router-view></router-view>
            </div>
        </div>
    </div>
</template>
<script>
import SubMenu from "@/components/SubMenu.vue";
import { mapState } from "vuex";

//菜单列表
const menuList = [
    {
        path: "/home",
        title: "菜单一"
    },
    {
        path: "/home-2",
        title: "菜单二",
        children: [
            {
                path: "/home-2-1",
                title: "菜单2-1"
            },
            { path: "/home-2-2", title: "菜单2-2" }
        ]
    },
    {
        path: "/home-2",
        title: "菜单二",
        children: [
            {
                path: "/home-2-1",
                title: "菜单2-1"
            },
            { path: "/home-2-2", title: "菜单2-2" }
        ]
    },
    {
        path: "/home-2",
        title: "菜单二",
        children: [
            {
                path: "/home-2-1",
                title: "菜单2-1"
            },
            { path: "/home-2-2", title: "菜单2-2" }
        ]
    },
    {
        path: "/home-2",
        title: "菜单二",
        children: [
            {
                path: "/home-2-1",
                title: "菜单2-1"
            },
            { path: "/home-2-2", title: "菜单2-2" }
        ]
    },
    {
        path: "/home-2",
        title: "菜单二",
        children: [
            {
                path: "/home-2-1",
                title: "菜单2-1"
            },
            { path: "/home-2-2", title: "菜单2-2" }
        ]
    },
    {
        path: "/home-2",
        title: "菜单二",
        children: [
            {
                path: "/home-2-1",
                title: "菜单2-1"
            },
            { path: "/home-2-2", title: "菜单2-2" }
        ]
    },
    {
        path: "/home-2",
        title: "菜单二",
        children: [
            {
                path: "/home-2-1",
                title: "菜单2-1"
            },
            { path: "/home-2-2", title: "菜单2-2" }
        ]
    }
];

export default {
    components: {
        "sub-menu": SubMenu
    },
    computed: {
        ...mapState(["systemName"])
    },
    data() {
        return {
            menuList
        };
    },
    methods: {
        //切换路由
        onItemClick(val) {
            console.log(val);
        }
    }
};
</script>
<style lang="less">
@import "../theme.less";
.basic-layout-page {
    .basic-layout-header {
        color: @theme-text-color;
        background-color: @theme-bg-color;
        display: flex;
        height: 56px;
        align-items: center;
        justify-content: space-between;
        padding: 0 12px;
        .left {
            flex: 1;
            display: flex;
            align-items: center;
            .title {
                min-width: 240px;
                font-size: 20px;
                font-weight: bold;
                padding: 0 15px;
                margin-right: 15px;
                text-shadow: 0 0 5px @theme-text-color;
            }
            .menu {
                width: 70%;
                min-width: 200px;
            }
        }
        .right {
            min-width: 200px;
            text-align: right;
            span.name {
                padding: 0 8px;
            }
        }
    }
    .basic-layout-content {
        background-color: #eee;
        padding: 10px 10px;
        .basic-layout-container {
            background-color: #fff;
            height: calc(100vh - 56px - 20px);
            padding: 10px 15px;
            overflow-y: auto;
        }
    }
}
</style>
